

export class PermissionUtils {



         static saveImageToPhone(tempFilePath) {
            // 检查授权状态
            wx.getSetting({
                success(settingData) {
                    if (!settingData.authSetting['scope.writePhotosAlbum']) {
                        // 请求授权
                        wx.authorize({
                            scope: 'scope.writePhotosAlbum',
                            success() {
                                this.saveWithPermission(tempFilePath);
                            },
                            fail() {
                                console.log('用户拒绝授权');
                            }
                        });
                    } else {
                        this.saveWithPermission(tempFilePath);
                    }
                }
            });
        }

         static saveWithPermission(tempFilePath) {
            wx.saveImageToPhotosAlbum({
                filePath: tempFilePath,
                success() {
                    console.log('保存成功');
                    wx.showToast({ title: '保存成功' });
                },
                fail(err) {
                    console.error('保存失败:', err);
                    wx.showToast({ title: '保存失败', icon: 'none' });
                }
            });
        }



}


